﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/AdminDefault.Master"
  AutoEventWireup="true" CodeBehind="ProCategoryList.aspx.cs" Inherits="NguyenHoa.Web.Admin.ProCategoryList" %>

<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <div>
    <dxwgv:ASPxGridView ID="gvList" runat="server" AutoGenerateColumns="False" ClientInstanceName="gvList"
      KeyFieldName="Id" Width="100%" OnCustomJSProperties="gvList_CustomJSProperties"
      OnRowDeleting="gvList_RowDeleting" OnRowInserting="gvList_RowInserting" OnRowUpdating="gvList_RowUpdating"
      OnCustomCallback="gvList_CustomCallback" OnCellEditorInitialize="gvList_CellEditorInitialize"
      OnCommandButtonInitialize="gvList_CommandButtonInitialize" OnDataBound="gvList_DataBound">
      <SettingsBehavior ConfirmDelete="True" />
      <Styles>
        <Header ImageSpacing="5px" SortingImageSpacing="5px">
        </Header>
      </Styles>
      <SettingsPager>
        <AllButton>
          <Image Height="19px" Width="28px" />
        </AllButton>
        <FirstPageButton>
          <Image Height="19px" Width="23px" />
        </FirstPageButton>
        <LastPageButton>
          <Image Height="19px" Width="23px" />
        </LastPageButton>
        <NextPageButton>
          <Image Height="19px" Width="19px" />
        </NextPageButton>
        <PrevPageButton>
          <Image Height="19px" Width="19px" />
        </PrevPageButton>
        <Summary AllPagesText="<%$Resources:Strings, PagerText %>" Text="<%$Resources:Strings, PagerText %>" />
      </SettingsPager>
      <Columns>
        <dxwgv:GridViewCommandColumn Name="Command" ButtonType="Image" VisibleIndex="0" 
          Width="60px" Caption=" ">
          <EditButton Visible="True">
            <Image Url="~/images/edit.png" />
          </EditButton>
          <NewButton Visible="True">
            <Image Url="~/images/add.png" />
          </NewButton>
          <DeleteButton Visible="True">
            <Image Url="~/images/delete.png" />
          </DeleteButton>
          <CancelButton>
            <Image Url="~/images/undo.gif" />
          </CancelButton>
          <UpdateButton>
            <Image Url="~/images/save.png" />
          </UpdateButton>
          <HeaderStyle HorizontalAlign="Center" />
          <CellStyle Cursor="pointer">
          </CellStyle>
        </dxwgv:GridViewCommandColumn>
        <dxwgv:GridViewDataTextColumn VisibleIndex="0" Caption="<%$ Resources:Strings, Name %>"
          FieldName="Name">
          <EditFormSettings Visible="True" VisibleIndex="0" />
          <HeaderStyle HorizontalAlign="Center" />          
        </dxwgv:GridViewDataTextColumn>
        <dxwgv:GridViewDataDateColumn FieldName="CreatedDate" VisibleIndex="1" Caption="<%$ Resources:Strings, CreatedDate %>">
          <HeaderStyle HorizontalAlign="Center" />
          <CellStyle HorizontalAlign="Center">
          </CellStyle>
        </dxwgv:GridViewDataDateColumn>
        <dxwgv:GridViewDataTextColumn FieldName="CreatedBy" VisibleIndex="2" Caption="<%$ Resources:Strings, CreatedBy %>">
          <HeaderStyle HorizontalAlign="Center" />
          <EditFormSettings Visible="True" VisibleIndex="1" />
         
        </dxwgv:GridViewDataTextColumn>
        <dxwgv:GridViewDataTextColumn Name="Locale">
          <EditFormSettings Visible="False" />
          <DataItemTemplate>
            <span><a style="cursor: pointer;" onclick="ViewDetail('<%#Eval("Id") %>')">
              <asp:Label runat="server" Text="<%$Resources:Strings,ViewDetail %>"></asp:Label></a>
            </span>
          </DataItemTemplate>
          <CellStyle HorizontalAlign="Center">
          </CellStyle>
        </dxwgv:GridViewDataTextColumn>
      </Columns>
      <StylesEditors>
        <ProgressBar Height="29px">
        </ProgressBar>
      </StylesEditors>
      <ImagesEditors>
        <CalendarPrevYear Height="19px" Width="23px" />
        <CalendarPrevMonth Height="19px" Width="19px" />
        <CalendarNextMonth Height="19px" Width="19px" />
        <CalendarNextYear Height="19px" Width="23px" />
      </ImagesEditors>
      <SettingsText ConfirmDelete="<%$Resources:Messages,ERR0006 %>" />
      <ClientSideEvents EndCallback="function(s,e){gvList_EndCallback(s,e);}"/>
    </dxwgv:ASPxGridView>
  </div>
  <asp:XmlDataSource ID="xdsLanguage" runat="server" DataFile="~/App_Data/Status.xml"
    XPath="Items/LanguageDisplay/Status"></asp:XmlDataSource>
  <dxpc:ASPxPopupControl ID="pcLocale" ClientInstanceName="pcLocale" runat="server"
    Width="420px" Modal="True" CloseAction="CloseButton" PopupVerticalAlign="WindowCenter"
    AllowDragging="True" PopupHorizontalAlign="WindowCenter"
    HeaderText="<%$ Resources:Strings, Category %>">
    <SizeGripImage Height="12px" Width="12px" />
    <CloseButtonImage Height="17px" Width="17px"></CloseButtonImage>
    <ContentCollection>
      <dxpc:PopupControlContentControl>
        <table style="padding: 10px;" width="100%" class="CommonFont">
          <tr>
            <td>
              <asp:Literal runat="server" Text="<%$ Resources:Strings, Language %>"></asp:Literal>
              :</td>
            <td>
              <dxe:ASPxComboBox ID="cbxLanguage" SelectedIndex="0" runat="server" DataSourceID="xdsLanguage"
                TextField="Value" ValueField="Id" ValueType="System.Int32" ClientInstanceName="cbxLanguage"
                Width="200px">
                <ButtonStyle Width="13px">
                </ButtonStyle>
                <ValidationSettings>
                  <ErrorImage Height="14px" Width="14px" />
                </ValidationSettings>
                <ClientSideEvents SelectedIndexChanged="function(s,e){oncbxLanguage_SelectedIndexChanged(s,e)}">
                </ClientSideEvents>
              </dxe:ASPxComboBox>
            </td>
          </tr>
          <tr>
            <td>
              <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:Strings, Name %>"></asp:Literal>
              :</td>
            <td>
              <dxe:ASPxTextBox ID="txtNameLocale" ClientInstanceName="txtNameLocale" runat="server"
                Width="300px">
              </dxe:ASPxTextBox>
            </td>
          </tr>
          <tr>
            <td>
              <asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:Strings, Description %>"></asp:Literal>
              :</td>
            <td>
              <dxe:ASPxMemo ID="mmDescription" ClientInstanceName="mmDescription" runat="server"
                Height="71px" Width="300px">
              </dxe:ASPxMemo>
            </td>
          </tr>
          <tr>
            <td>
            </td>
            <td>
              <table>
                <tr>
                  <td>
                    <dxe:ASPxButton ID="btnSaveLocale" ClientInstanceName="btnSaveLocale" runat="server"
                      Text="<%$ Resources:Strings, Save %>" AutoPostBack="false">
                      <ClientSideEvents Click="function(s,e){btnSaveLocale_Click();}" />
                    </dxe:ASPxButton>
                  </td>
                  <td>
                    <dxe:ASPxButton ID="btnCancel" ClientInstanceName="btnCancel" runat="server" Text="<%$ Resources:Strings,  Cancel %>"
                      AutoPostBack="false">
                      <ClientSideEvents Click="function(s,e){btnCancel_Click();}" />
                    </dxe:ASPxButton>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </dxpc:PopupControlContentControl>
    </ContentCollection>
  </dxpc:ASPxPopupControl>
  <asp:HiddenField ID="hfCategoryId" runat="server" />
  <asp:HiddenField ID="hfLocaleId" runat="server" />
  <dxcb:ASPxCallback ID="CtrlCallback" ClientInstanceName="CtrlCallback" runat="server"
    OnCallback="CtrlCallback_Callback">
    <ClientSideEvents CallbackComplete="function(s,e){CtrlCallback_CallbackComplete(s,e);}" />
  </dxcb:ASPxCallback>

  <script type="text/javascript" language="javascript">

    function btnSaveLocale_Click() {
      //gvList.PerformCallback('locale');
      CtrlCallback.SendCallback('save');
    }
    function btnCancel_Click() {
      pcLocale.Hide();
      txtNameLocale.SetText('');
      mmDescription.SetText('');
    }
    function gvList_EndCallback(s, e) {
      var error = gvList.cpInnerError;
      if (error != '') {
        alertMessage(error.split('|')[1]);
      }
      else {
        pcLocale.Hide();
      }
    }
    function ViewDetail(id) {
      document.getElementById("<%=hfCategoryId.ClientID %>").value = id;
      pcLocale.Show();
      //setTimeout("CtrlCallback.SendCallback('loadlocale')", 10);
      CtrlCallback.SendCallback('loadlocale');
    }
    function CtrlCallback_CallbackComplete(s, e) {
      //alert(e.result);
      //alert(e.result.split('|'));
      var values = e.result.split('|');
      if (values[0].indexOf('[locale]') != -1) {
        pcWaiting.Hide();
        document.getElementById("<%=hfLocaleId.ClientID %>").value = values[1];
        txtNameLocale.SetText(values[2]);
        mmDescription.SetText(values[3]);
      }
      else if (values[0].indexOf('[save]') != -1) {
        alertMessage('<%=(string)GetGlobalResourceObject("Messages","ERR0005") %>');
      }
      else if (values[0].indexOf('error') != -1) {
       
        alertMessage(values[1]);
      }
    }
    function oncbxLanguage_SelectedIndexChanged(s, e) {
      CtrlCallback.SendCallback('loadlocale');
    }
  </script>

</asp:Content>
